import 'dart:math';

import 'package:catguard/global/global_data.dart';
import 'package:catguard/routers/routers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:line_awesome_flutter/line_awesome_flutter.dart';
import 'package:roundcheckbox/roundcheckbox.dart';

import '../../../config/config.dart';
import '../../../generated/assets.dart';
import '../../../views/common_widget.dart';
import 'device_tips_logic.dart';

class DeviceTipsPage extends StatelessWidget {
  DeviceTipsPage({super.key});

  final logic = Get.find<DeviceTipsLogic>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Config.colorBg,
      resizeToAvoidBottomInset: false,
      body: Column(
        children: [
          CommonWidget.commonAppBar("进入配网模式"),
          Container(
            width: double.infinity,
            margin: EdgeInsets.only(top: 30.w, left: 35.w, right: 35.w),
            padding: EdgeInsets.symmetric(horizontal: 35.w, vertical: 35.w),
            decoration: BoxDecoration(
              color: Config.colorBg2,
              borderRadius: BorderRadius.circular(Config.roundBig.w),
            ),
            child: Column(
              children: [
                Image.asset(Assets.imagesProduct01Big, width: 500.w),
                SizedBox(
                  height: 20.w,
                ),
                Row(
                  children: [
                    SizedBox(
                      width: 66.w,
                    ),
                    Text(
                      "1.将设备插上电源",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: Config.textSizeInfo.sp, color: Config.colorText1, height: 1.8),
                    ),
                  ],
                ),
                Row(
                  children: [
                    SizedBox(
                      width: 66.w,
                    ),
                    Text(
                      "2.点击屏幕右侧开机按键",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: Config.textSizeInfo.sp, color: Config.colorText1, height: 1.8),
                    ),
                  ],
                ),
                Row(
                  children: [
                    SizedBox(
                      width: 66.w,
                    ),
                    Text(
                      "3.点击配置网络按钮",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: Config.textSizeInfo.sp, color: Config.colorText1, height: 1.8),
                    ),
                  ],
                ),
              ],
            ),
          ),
          GestureDetector(
            onTap: () {
              logic.isCheckReady.value = !logic.isCheckReady.value;
            },
            child: Container(
              margin: EdgeInsets.only(top: 40.w, left: 45.w, right: 45.w),
              child: Obx(
                () => Row(
                  children: [
                    RoundCheckBox(
                      onTap: (selected) {
                        logic.isCheckReady.value = selected!;
                      },
                      size: 38.w,
                      isChecked: logic.isCheckReady.value,
                      checkedWidget: Icon(
                        Icons.check,
                        size: 28.w,
                        color: Config.colorBg2,
                      ),
                      // checkedColor: Config.colorMain,
                    ),
                    SizedBox(
                      width: 15.w,
                    ),
                    Text(
                      "已确认设备进入配网模式",
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: Config.textSizeContent.sp,
                          color: Config.colorText1,
                          height: 1.6),
                    ),
                  ],
                ),
              ),
            ),
          ),
          Expanded(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Obx(
                  () => Opacity(
                    opacity: logic.isCheckReady.value ? 1 : 0.4,
                    child: CommonWidget.commonButton("下一步", () {
                      if( logic.isCheckReady.value){
                        Get.offNamed(Routes.deviceSearch);
                      }
                    }, width: 650.w, radius: 50.w),
                  ),
                ),
                SizedBox(height: 120.w)
              ],
            ),
          ),
        ],
      ),
    );
  }
}
